﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace TweetJSON.JSON.Entity
{
    
    public class Tweet
    {
        public virtual string text { get; set; }
        public virtual Int64 id { get; set; }
        public virtual TwitterUser user { get; set; }
        public virtual string created_at { get; set; }
        public virtual string retweet_count  { get; set; }
        [JsonIgnore]
        public virtual int RetweetCount
        {
            get
            {
                int count = 100;
                try
                {
                    count = Int32.Parse(retweet_count);
                }
                catch
                {
                    count = 100;
                }
                return count;
            }
        }
        [JsonIgnore]
        public virtual double latitude {
            get
            {
                if (retweeted_status != null)
                {
                    return retweeted_status.geo.coordinates.First<Double>();
                }
                else
                {
                    return geo.coordinates.First<Double>();
                }
            }
        }
        [JsonIgnore]
        public virtual double longitude
        {
            get
            {
                if (retweeted_status != null)
                {
                    return retweeted_status.geo.coordinates.Last<Double>();
                }
                else
                {
                    return geo.coordinates.Last<Double>();
                }
            }
        }
        public virtual GeoInfo geo { get; set; }
        public virtual Tweet retweeted_status { get; set; }
        public virtual TweetEntity entities { get; set; }

    }
    
}
